package com.czxy.changgou3.controller;

import com.czxy.changgou3.utils.PayHelper;
import com.czxy.changgou3.vo.PayRequest;
import com.czxy.vo.BaseResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zhangmengxiang1@itcast.cn
 * @version 1.0
 * @date 2020/5/5
 */
@RestController
@RequestMapping("/pay")
public class PayController {

    @Resource
    private PayHelper payHelper;

    @PostMapping
    public BaseResult pay(@RequestBody PayRequest payRequest){
        String payUrl = payHelper.createPayUrl(payRequest.getSn());
        return BaseResult.ok("二维码生产成功").append("wxurl",payUrl);
    }
}

